/*
 * $Id: fsm_error.c,v 1.4 2005-09-25 08:42:24 bacon Exp $
 */

#include <xp/utl/fsm.h>
#include <xp/bas/string.h>

static const xp_char_t* __errstr[] =
{
	XP_TEXT("no error"),
	XP_TEXT("cancelled"),
	XP_TEXT("out of memory"),
	XP_TEXT("wrong path specified"),
	XP_TEXT("no source found"),
	XP_TEXT("same source and target"),
	XP_TEXT("cannot rename source"),
	XP_TEXT("cannot delete source"),
	XP_TEXT("not copyable to a directory"),
	XP_TEXT("access or permission denied"),
	XP_NULL
};

int xp_fsm_error (xp_fsm_t* fsm, xp_char_t* errbuf, xp_size_t size)
{
	if (errbuf == XP_NULL || size == 0) return fsm->errnum;
	xp_strxcpy (errbuf, size, __errstr[fsm->errnum]);
	return fsm->errnum;
}
